
Technical Q&A's
OPS 10 - Impossibility of Extracting File System Information from the WindowPtr (14-May-96)
Q I need to get the full pathname to a document in a callback where the only
relevant piece of information I have is the WindowPtr for the window that will
contain the document. I know the filename, but I do not know the directory ID
or volume reference number. Is there any way to obtain the dirID and vRefNum
from the WindowRecord?
A Unfortunately, there is no way to extract the file system information you need
from a WindowRecord. The WindowRecord includes only structural human interface
information which might include the file name (actually the document's title).
Windows provide a means of presenting the data of documents for the user, but
the WindowRecords have no knowledge of where to find the file system
information. As you have implied, you must have the directory ID and volume
reference number to extract a full pathname.
Knowing the vRefNum and the parent dirID, you would be able to use one of the
FullPath routines in the DTS Sample Code MoreFiles.
If you knew the file reference number, you could call PBGetFCBInfo() to get the
vRefNum and dirID, then use MoreFiles to get your full pathname.
PBGetFCBInfo() gives information about open files (files in the file control
block queue). You call PBGetFCBInfo() like this:
pascal OSErr GetFileLocation(short refNum,
short *vRefNum,
long *dirID,
StringPtr fileName)
{
FCBPBRec pb;
OSErr error;
pb.ioNamePtr = fileName;
pb.ioVRefNum = 0;
pb.ioRefNum = refNum;
pb.ioFCBIndx = 0;
error = PBGetFCBInfoSync(&pb);
*vRefNum = pb.ioFCBVRefNum;
*dirID = pb.ioFCBParID;
return (error);
}
See Also:
- For more information on File Control Blocks, see Inside Macintosh: Files,
pp. 2-81 through 2-83.
- For more information on PBGetFCBInfo, see Inside Macintosh: Files, pp.
2-237 through 2-238.
Technical Support
Technical Q&As
Previous Question | Contents | Next Question

Main |
Page One |
What's New |
Apple Computer, Inc. |
Find It |
Contact Us |
Help